package easy.netty.net.core;

import io.netty.channel.Channel;

/**
 * @author cengy
 */
public interface IoSession {

    void setEntity(Entity entity);

    Entity getEntity();

    void setId(String id);

    String getId();

    void onOpen();

    void onClose();

    void onRead(Object message);

    void onError(Throwable t);

    void onEvt(Object evt);

    void setChannel(Channel channel);

    Channel getChannel();

    void send(Object message);

    void send(Object message, SendMessageCallback callback);

    interface SendMessageCallback {

        void onSuccess(Channel ch, Object message);

        void onFailure(Channel ch, Object message, Throwable t);
    }
}
